﻿using System;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using MobileLoader.DataSet;

namespace MobileLoader.Controls
{
    public partial class PrintListFilterXtraForm : XtraForm
    {

        public TMNLojasDataSet ShopData
        {
            set
            {
                tmnLojasDataSet = value;
                shopLookUpEdit.Properties.Columns.Clear();
                shopLookUpEdit.Properties.Columns.AddRange(new[]
                                                           {
                                                               new LookUpColumnInfo("SAP", "SAP", 85, FormatType.None, "", false, HorzAlignment.Near),
                                                               new LookUpColumnInfo("Nome", "Nome", 85, FormatType.None, "", true, HorzAlignment.Near)
                                                           });
                shopLookUpEdit.Properties.DisplayMember = tmnLojasDataSet.Loja.NomeColumn.ColumnName;
                shopLookUpEdit.Properties.ValueMember = tmnLojasDataSet.Loja.SAPColumn.ColumnName;
                shopLookUpEdit.Properties.DataSource = tmnLojasDataSet.Loja;
            }
        }

        public DateTime Date
        {
            get { return dateEdit.DateTime;  }
        }

        public int Shop
        {
            get { return shopLookUpEdit.EditValue == null ? -1 : Convert.ToInt32(shopLookUpEdit.EditValue); }
        }

        public PrintListFilterXtraForm()
        {
            InitializeComponent();
            okSimpleButton.Click += OkSimpleButtonClick;
        }

        void OkSimpleButtonClick(object sender, EventArgs e)
        {
            if (dateEdit.EditValue != null)
                return;
            dxErrorProvider.SetError(dateEdit, "Por favor, seleccione o dia a imprimir.");
            DialogResult = DialogResult.None;
        }
    }
}